import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'

const routes = [
    {
        path: '/',
        redirect: '/index',
        name: 'index',
        component: () => import("../views/baseLayout"),
        children: [
            {
                path: "/index",
                component: () => import("../views/index")
            },
            {
                path: "/judge",
                component: () => import("../views/judge")
            },
            {
                path: "/my",
                component: () => import("../views/my")
            },
            {
                path: "/manage",
                component: () => import("../views/manage")
            }
        ]
    },
    {
        path: '/competition',
        component: () => import("../views/competition")
    },
    {
        path: '/issueCompetition',
        component: () => import("../views/issueCompetition")
    },
    {
        path: '/setJudge/:now',
        component: () => import("../views/setJudge")
    },
    {
        path: '/work',
        name: "work",
        component: () => import("../views/work")
    },
    {
        path: '/download',

        component: () => import("../views/download")
    },
    {
        path: '/login',

        component: () => import("../views/login")
    },
    {
        path: '/issueNotice',

        component: () => import("../views/issueNotice")
    },
        {
        path: '/notice/:id',

        component: () => import("../views/notice")
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})
router.beforeEach((to, from, next)=>{
  var telephone = window.localStorage.getItem("telephone")
 if(telephone==''||telephone==undefined){
    if(to.path!='/my'&&to.path!='/competition') next()
      else{
    next('/login')
  }
  }

  return  next()


})
export default router
